<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文章统计</title>
    <script src="../../js/echarts-all.js" type="text/javascript"></script>
    <script src="../../js/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script>
        $(function (){
            // 基于准备好的dom，初始化echarts图表
            var myChart = echarts.init(document.getElementById('main'));
            $.get("../../journalism/getjournalismnum",function (res){
                if (res.code == 202){
                    window.parent.location.replace("../login.html");
                }else if (res.code == 500){
                    alert(res.msg);
                } else {
                    option = {
                        title: {
                            text: '每种类型的文章有多少篇',//标题
                            subtext: '真实数据'//副标题
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        legend: {
                            data: ['平均数']
                        },
                        toolbox: {
                            show: true,
                            feature: {
                                mark: {show: true},
                                dataView: {show: true, readOnly: false},
                                magicType: {show: true, type: ['line', 'bar']},
                                restore: {show: true},
                                saveAsImage: {show: true}
                            }
                        },
                        calculable: true,
                        xAxis: [
                            {
                                type: 'category',
                                boundaryGap: false,
                                data: res.data.x
                            }
                        ],
                        yAxis: [
                            {
                                type: 'value'
                            }
                        ],
                        series: [
                            {
                                name: '文章数量',
                                type: 'line',
                                data: res.data.y,
                                markPoint: {
                                    data: [
                                        {type: 'max', name: '最大值'},
                                        {type: 'min', name: '最小值'}
                                    ]
                                },
                                markLine: {
                                    data: [
                                        {type: 'average', name: '平均值'}
                                    ]
                                }
                            }
                        ]
                    };
                }
                // 为echarts对象加载数据
                myChart.setOption(option);
            })
        })
    </script>
</head>
<body>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="height:400px"></div>
</body>
</html>